ubyte
A simple, complete, const
-everything, saturating, human-friendly, #![no_std]
Rust library for byte units.
use ;
// Constructors and associated units for all SI units up to exbibyte.
let half_mb = 500.kilobytes;
let half_mb = Kilobyte;
let half_mb = 500 * kB;
// All arithmetic and conversions are saturating.
let exbibyte_too_large_a = 1024 * EiB;
let exbibyte_too_large_b = Exbibyte;
let exbibyte_too_large_c = 1024.exbibytes;
assert_eq!;
assert_eq!;
assert_eq!;
// Printing is human-friendly and customizeable.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Parsing is intuitive.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
See the documentation for detailed usage information.
Usage
Add the following to your Cargo.toml
:
[]
= "0.10"
For serde
(de)serialization support, enable the serde
feature, which is
disabled by default:
[]
= { = "0.10", = ["serde"] }
License
ubyte
is licensed under either of the following, at your option:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in ubyte
by you shall be dual licensed as above without any
additional terms or conditions.